扩展:现在随心所欲地定制您的程序!至少改变你的程序的三件事。

  1. 更改背景通过更改.set_background()中的"string"
  2. 更改两个.say()中的字符串以说出其他内容!
  3. 更改if · distance · <= · 200中的整数: ¬并运行您的代码以查看它产生的差异。
  4. 完成后,单击提交下一个。

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("schoolentrance") stage.wait(2) stage.create_grid_overlay(50, "blue") stage.set_background_color("azure") emma = codesters.Sprite("person1") emma.set_size(0.5) michael = codesters.Sprite("person2") michael.set_size(0.5) emma_x = random.randint(-230,230) emma_y = random.randint(-230,230) emma.go_to(emma_x, emma_y) michael_x = random.randint(-230,230) michael_y = random.randint(-230,230) michael.go_to(michael_x, michael_y) delta_x = emma_x - michael_x delta_y = emma_y - michael_y distance = math.sqrt((delta_x**2) + (delta_y**2)) if distance <= 200: # add your code here emma.say("I am a sprite.") emma.load_image("person1_masked") michael.load_image("person2_masked") else: michael.say("I am a sprite.")
  • Run Code
  • 提交作品
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)